package com.java.laixiangdong.express.server;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @Author: laixiangdong
 * @Date 2020/10/26
 */
public class ServerExpressPlaceSave {
    public static void main(String[] args) throws IOException {
        ServerSocket server = new ServerSocket(56603);

        while (true) {
            try (Socket socket = server.accept()) {
                new Thread(() -> {
                    try {
                        InputStream inputStream = socket.getInputStream();
                        byte[] bytes = inputStream.readAllBytes();

                        OutputStream outputStream = new FileOutputStream("expressPlaces.save");
                        outputStream.write(bytes);
                        System.out.println("保存expressPlaces.save成功");
                    } catch (IOException e) {
                        System.out.println("保存expressPlaces.save失败");
                    }
                }).start();
            }
        }
    }
}
